package lex.mxbeans.utils;

import java.util.Collection;

public class MXBeanInfo
{
	private final String name;
	private final Object[] beans;

	@SuppressWarnings( "unchecked" )
	public MXBeanInfo( String name, Object bean )
	{
		this.name = name;
		if( bean instanceof Collection )
			this.beans = ((Collection) bean).toArray();
		else
			this.beans = new Object[]{ bean };
	}

	public String getName()
	{
		return name;
	}

	public Object[] getBeans()
	{
		return beans;
	}

	public String toString()
	{
		if( beans.length > 1 )
			return this.name + " [" + beans.length + " items]";
		else
			return name;
	}
}
